/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package intopo.evogame.partnerselection.config;

/**
 * Thrown to indicate that an unknown tag was read from a configuration file.  When constructing game and strategy instances from data in a file, the data
 * is preceded by a tag.  This tag is used in an associative memory to retrive the constructor.
 *
 * @author pedro
 */
public class TagException
		  extends Exception {

	/**
	 * The tag that was read from a configuration file.
	 */
	final private String tag;
	/**
	 * Indicates what the tag was used for.  If it was used to construct a game or a strategy instance.
	 */
	final private Entity entity;

	/**
	 * Creates a new instance of <code>TagException</code> without detail message.
	 */
	public TagException (Entity entity, String tag)
	{
		this.tag = tag;
		this.entity = entity;
	}

	/**
	 * Constructs an instance of <code>TagException</code> with the specified detail message.
	 * @param msg the detail message.
	 */
	public TagException (Entity entity, String tag, String msg)
	{
		super (msg);
		this.entity = entity;
		this.tag = tag;
	}

	public String getTag ()
	{
		return this.tag;
	}

	public Entity getEntity ()
	{
		return this.entity;
	}
	/**
	 * Get a message that can be displayed to the user.  This message can be used in the console or in a label.
	 * @return
	 */
	public String getUserMessage ()
	{
		StringBuffer sb = new StringBuffer ();
		sb.append ("Tag '");
		sb.append (this.tag);
		sb.append (" does not match any of the keys in the ");
		sb.append (this.entity);
		sb.append (" map");
		return sb.toString ();
	}
	/**
	 * Enumeration that indicates what the tag was used for.
	 */
	public enum Entity
	{
		STRATEGY,
		GAME;
	}
}
